home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / initrd.lz / initrd / scripts / casper-premount / 10driver_updates next >
Encoding:
Text File  |  2009-10-28  |  3.1 KB  |  150 lines

  1. #!/bin/sh
  2.  
  3. PREREQ=""
  4. . /scripts/casper-functions
  5. . /scripts/casper-helpers
  6.  
  7. prereqs()
  8. {
  9.        echo "$PREREQ"
  10. }
  11.  
  12. case $1 in
  13. # get pre-requisites
  14. prereqs)
  15.        prereqs
  16.        exit 0
  17.        ;;
  18. esac
  19.  
  20. mountpoint=/cdrom
  21.  
  22. is_updates_path() {
  23.     # Driver packages are stored in ubuntu-drivers/<kver>/
  24.     # subdirectory. Each package contains a module for a specific
  25.     # kernel flavour.
  26.     path=$1
  27.     abi="$(uname -r)"
  28.     kver="$(echo "$abi" | cut -d- -f1,2)"
  29.     kbase="$(echo "$abi" | cut -d- -f1)"
  30.     for leaf in "$abi" "$kver" "$kbase"; do
  31.         update_dir="$path/ubuntu-drivers/$leaf"
  32.         [ -d "$update_dir" ] || continue
  33.         if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \
  34.             "$update_dir/*_$DPKG_ARCH.deb" ]; then
  35.             echo "$update_dir"
  36.             return 0
  37.         fi
  38.     done
  39.     return 1
  40. }
  41.  
  42. is_nice_device() {
  43.     sysfs_path="${1#/sys}"
  44.     if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"; then
  45.         return 0
  46.     fi
  47.     return 1
  48. }
  49.  
  50. check_dev_updates ()
  51. {
  52.     sysdev="${1}"
  53.     devname="${2}"
  54.     if [ -z "${devname}" ]; then
  55.         devname=$(sys2dev "${sysdev}")
  56.     fi
  57.  
  58.     fstype=$(get_fstype "${devname}")
  59.     if is_supported_fs ${fstype}; then
  60.         mount -t ${fstype} -o ro "${devname}" $mountpoint || continue
  61.         if is_updates_path $mountpoint; then
  62.             return 0
  63.         else
  64.             umount $mountpoint
  65.         fi
  66.     fi
  67.  
  68.     return 1
  69. }
  70.  
  71. find_driver_updates() {
  72.     for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do
  73.         devname=$(sys2dev "${sysblock}")
  74.         fstype=$(get_fstype "${devname}")
  75.         if /lib/udev/cdrom_id ${devname} > /dev/null; then
  76.             if check_dev_updates "null" "${devname}" ; then
  77.                 return 0
  78.             fi
  79.         elif is_nice_device "${sysblock}" ; then
  80.             for dev in $(subdevices "${sysblock}"); do
  81.                 if check_dev_updates "${dev}" ; then
  82.                     return 0
  83.                 fi
  84.             done
  85.         fi
  86.     done
  87.     return 1
  88. }
  89.  
  90.  
  91. updates="false"
  92.  
  93. for x in $(cat /proc/cmdline); do
  94.     case $x in
  95.         debian-installer/driver-update=*)
  96.             updates=${x#debian-installer/driver-update=}
  97.             ;;
  98.     esac
  99. done
  100.  
  101. if [ "$updates" != "true" ]; then
  102.     log_end_msg
  103.     exit 0
  104. fi
  105.  
  106. # Not sure what to do for network installs. I assume there isn't even a CD
  107. # for this anyway, so fail.
  108. if [ -n "${NETBOOT}" ]; then
  109.     log_end_msg
  110.     exit 0;
  111. fi
  112.  
  113. #if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then
  114. #    GDMCONF=/etc/gdm/gdm-cdd.conf
  115. #else
  116. #    GDMCONF=/etc/gdm/gdm.conf
  117. #fi
  118.  
  119. eject
  120. log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)"
  121.  
  122. log_begin_msg "Looking for driver update CD"
  123.  
  124. for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do
  125.     updates_root=$(find_driver_updates)
  126.     if [ "${updates_root}" ]; then
  127.         break;
  128.     fi
  129.     sleep 1
  130. done
  131.  
  132. log_end_msg
  133.  
  134. if [ -z "${updates_root}" ]; then
  135.     log_begin_msg "Could not find driver updates"
  136.     log_wait_msg "Re-insert install CD and press ENTER"
  137.     exit 0
  138. fi
  139.  
  140. log_begin_msg "Copying driver updates to temporary location"
  141.  
  142. mkdir -p /tmp/driver-updates
  143. cp $updates_root/*_$DPKG_ARCH.deb /tmp/driver-updates/
  144. umount $mountpoint
  145. eject
  146.  
  147. log_end_msg
  148.  
  149. log_wait_msg "Re-insert install CD and press ENTER."
  150.